/**
 * 
 */
package No101_200.No151_160.MinStack_155;

/**
 * @author 李敬
 * 
 * 使用自定义类Node
 * class Node {  
 * 	int val;  
 * 	int min; 
 * 	Node next;  
 * 
 * 	public Node(int val) {
 * 		this.val = val;  
 * 	} 
 * 
 */
public class MinStack {
	Node top = null;
	
	/** initialize your data structure here. */
    public MinStack() {
        
    }
    
    public void push(int x) {
    	if (this.top == null) {
			this.top = new Node(x, x);
		} else {
			Node temp = new Node(x, (top.min<x)?top.min:x);
			temp.nextNode = this.top;
			this.top = temp;
		}
    }
    
    public void pop() {
        this.top = this.top.nextNode;
    }
    
    public int top() {
        return this.top.val;
    }
    
    public int getMin() {
    	return this.top.min;
    }

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}

class Node{
	int val;
	int min;
	Node nextNode;
	
	public Node(int val,int min) {
		this.val = val;
		this.min = min;
	}
}
